//
//  BaseTableViewController.swift
//  WeiboCY
//
//  Created by 林小陌 on 16/1/13.
//  Copyright © 2016年 林小陌. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    var  userLogin = false
    var vistorLoginView: VisitorLoginView?
    
    override func loadView() {
//        super.loadView()
        if userLogin{
            super.loadView()
        }else{
        
            vistorLoginView = VisitorLoginView()
            vistorLoginView?.visitorViewDelegate = self
            view = vistorLoginView
            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "userWillLogin")
        }
       
        
    }
    
    //MARK: 实现 VisitorLoginViewDelegate 协议方法
    func userWillRegister() {
        print(__FUNCTION__)
    }
    
    
    func userWillLogin() {
        print(__FUNCTION__)
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        //跳转到授权页面
        presentViewController(nav, animated: true, completion: nil)
    }
    
    
    
    
    
    
    
    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        print(view)
        print(view.classForCoder)
    }
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }



}
